package main

import (
	"danmu/controller"
	"danmu/middleware"

	"github.com/gin-gonic/gin"
)

func CollectRoute(r *gin.Engine) *gin.Engine {
	r.Use(middleware.CORSMiddleware())
	//用户相关
	r.POST("/api/auth/register", controller.Register)
	r.POST("/api/auth/login", controller.Login)
	r.POST("/api/auth/modifyInfo", middleware.AuthMiddleware(), controller.ModifyInfo)
	r.GET("/api/auth/userInfo", middleware.AuthMiddleware(), controller.UserInfo)
	r.GET("/api/userInfo", controller.GetInfoById)

	//视频相关
	r.POST("/api/upload/videoInfo", middleware.AuthMiddleware(), controller.UploadVideoInfo)
	r.POST("/api/video/modify", middleware.AuthMiddleware(), controller.ModifyVideo)
	r.POST("/api/video/delete", middleware.AuthMiddleware(), controller.DeleteVideo)
	r.GET("/api/video/mine", middleware.AuthMiddleware(), controller.GetMineVideo)
	r.GET("/api/video/getRecommend", controller.GetRecommend)
	r.GET("/api/video/videoList", controller.GetVideoList)
	r.GET("/api/video/videoInfo", controller.GetVideoInfo)

	//用户关系
	r.POST("/api/auth/follow", middleware.AuthMiddleware(), controller.Follow)
	r.POST("/api/auth/unsubscribe", middleware.AuthMiddleware(), controller.Unsubscribe)
	r.GET("/api/auth/isFollow", controller.IsFollow)
	r.GET("/api/auth/following", controller.GetFollowing)
	r.GET("/api/auth/follower", controller.GetFollower)
	r.GET("/api/auth/follow/count", controller.GetFollowCount)

	//评论
	r.POST("/api/comment", middleware.AuthMiddleware(), controller.Comment)
	r.POST("/api/comment/delete", middleware.AuthMiddleware(), controller.DeleteComment)
	r.GET("/api/getComment", controller.GetComment)

	//弹幕
	r.GET("/api/danmu/get", controller.GetDanmu)
	r.POST("/api/danmu/send", middleware.AuthMiddleware(), controller.SendDanmu)

	//消息系统
	r.GET("/api/message/unread",middleware.AuthMiddleware(),controller.GetUnreadMsg) //未读消息数
	r.GET("/api/message/announce", middleware.AuthMiddleware(), controller.GetAnnounce)
	r.GET("/api/message/list", middleware.AuthMiddleware(), controller.GetUserMessageList)
	r.GET("/api/message/get", middleware.AuthMiddleware(), controller.GetUserMessageById)
	r.POST("/api/message/send", middleware.AuthMiddleware(), controller.SendUserMessage)
	r.POST("/api/announce/read",middleware.AuthMiddleware(),controller.AnnounceRead) //已读通知
	r.POST("/api/message/read",middleware.AuthMiddleware(),controller.MsgHaveRead)//已读消息
	r.POST("/api/message/delete",middleware.AuthMiddleware(),controller.DeleteMessage)//删除消息

	//收藏
	r.GET("/api/favorites/get",middleware.AuthMiddleware(),controller.GetFavorites)
	r.GET("/api/interactive",middleware.AuthMiddleware(),controller.GetInteractive)
	r.POST("/api/favorites/add",middleware.AuthMiddleware(),controller.Favorites)
	r.POST("/api/favorites/cancel",middleware.AuthMiddleware(),controller.Unfavorite)

	//点赞
	r.POST("/api/like/add",middleware.AuthMiddleware(),controller.Like)
	r.POST("/api/like/cancel",middleware.AuthMiddleware(),controller.Dislike)

	//其他
	r.GET("/api/carousel/get",controller.GetCarousel)
	r.POST("/api/code/send",controller.SendCode)

	//搜索
	r.GET("/api/search",controller.Search)
	r.GET("/api/search/user",controller.SearchUser)

	//管理员
	r.POST("/api/admin/login",controller.AdminLogin)
	r.POST("/api/admin/add", middleware.AdminAuthMiddleware(), controller.AddAdmin)
	r.POST("/api/admin/delete", middleware.AdminAuthMiddleware(), controller.DeleteAdmin)
	r.GET("/api/admin/user/get",middleware.AdminAuthMiddleware(),controller.UserList)
	r.POST("/api/admin/user/modify",middleware.AdminAuthMiddleware(),controller.ModifyUserInfo)
	r.POST("/api/admin/user/delete",middleware.AdminAuthMiddleware(),controller.DeleteUser)
	r.GET("/api/admin/video/get", middleware.AdminAuthMiddleware(),controller.VideoInfoList)
	r.POST("/api/admin/video/modify",middleware.AdminAuthMiddleware(),controller.ModifyVideoInfo)
	r.POST("/api/admin/video/delete",middleware.AdminAuthMiddleware(),controller.AdminDeleteVideo)
	r.POST("/api/admin/announce/add",middleware.AdminAuthMiddleware(),controller.AddAnnounce)
	r.GET("/api/admin/announce/get",middleware.AdminAuthMiddleware(),controller.AnnounceList)
	r.POST("/api/admin/announce/delete",middleware.AdminAuthMiddleware(),controller.DeleteAnnounce)
	r.POST("/api/admin/carousel/upload",middleware.AdminAuthMiddleware(),controller.UploadCarouselInfo)
	r.POST("/api/admin/carousel/delete",middleware.AdminAuthMiddleware(),controller.DeleteCarouse)

	//文件资源
	r.GET("/image", controller.GetImage)
	r.GET("/userFace", controller.GetUserFace)
	r.GET("/cover", controller.GetCover)
	r.GET("/video", controller.GetVideo)
	r.POST("/api/upload/cover", middleware.AuthMiddleware(), controller.UploadCover)
	r.POST("/api/upload/face", middleware.AuthMiddleware(), controller.UploadFace)
	r.POST("/api/upload/video", middleware.AuthMiddleware(), controller.UploadVideo)
	r.POST("/api/upload/carousel",middleware.AdminAuthMiddleware(),controller.UploadCarousel)
	return r
}
